home *** CD-ROM | disk | FTP | other *** search
- /*
-
- dwarf_alloc.h
- $Revision: 1.13 $ $Date: 1994/06/17 02:39:05 $
-
- */
-
- Dwarf_Ptr _dwarf_get_alloc (Dwarf_Debug, Dwarf_Small, Dwarf_Unsigned);
- Dwarf_Debug _dwarf_get_debug (void);
- Dwarf_Debug _dwarf_setup_debug (Dwarf_Debug);
- int _dwarf_free_all_of_one_debug (Dwarf_Debug);
-
-
- /*
- This macro adds the size of a pointer to the size of a
- struct that is given to it. It rounds up the size to
- be a multiple of the size of a pointer. This is done
- so that every struct returned by _dwarf_get_alloc()
- can be preceded by a pointer to the chunk it came from.
- Before, it checks if the size of struct is less than
- the size of a pointer. If yes, it returns the size
- of 2 pointers. The returned size should be at least
- the size of 2 pointers, since the first points to the
- chunk the struct was allocated from, and the second
- is used to link the free list.
- */
- #define ROUND_SIZE_WITH_POINTER(a_struct) \
- (sizeof(a_struct) < sizeof(void *) ? \
- 2 * sizeof(void *) : \
- sizeof(a_struct) % sizeof(void *) == 0 ? \
- sizeof(a_struct) + sizeof(void *) : \
- sizeof(a_struct) + sizeof(void *) + sizeof(void *) - \
- (sizeof(a_struct) % sizeof(void *)))
-
-
- typedef struct Dwarf_Alloc_Area_s *Dwarf_Alloc_Area;
- typedef struct Dwarf_Free_List_s *Dwarf_Free_List;
-
-
- /*
- This struct is used to chain all the deallocated
- structs on the free list of each chain. The structs
- are chained internally, by using the memory they
- contain.
- */
- struct Dwarf_Free_List_s {
- Dwarf_Free_List fl_next;
- };
-
-
- /*
- This struct is used to manage all the chunks malloc'ed
- for a particular alloc_type. Many of the fields are
- initialized by dwarf_init().
- */
- struct Dwarf_Alloc_Hdr_s {
-
- /* Count of actual number of structs allocated. */
- Dwarf_Sword ah_struct_alloc_count;
-
- /*
- Size of each struct that will be allocated for
- this alloc_type. Initialized by dwarf_init().
- */
- Dwarf_Half ah_alloc_size;
-
- /*
- Number of structs of this alloc_type that will
- be contained in each chunk that is malloc'ed.
- Initialized by dwarf_init().
- */
- Dwarf_Word ah_alloc_num;
-
- /*
- Number of bytes malloc'ed per chunk, that is
- ah_alloc_size * ah_alloc_num.
- */
- Dwarf_Word ah_malloc_length;
-
- /* Count of chunks currently allocated for type. */
- Dwarf_Sword ah_curr_alloc;
-
- /* Max number of chunks ever allocated for type. */
- Dwarf_Sword ah_max_alloc;
-
- /*
- Points to a chain of Dwarf_Alloc_Area_s structs
- that represent all the chunks currently allocated
- for the alloc_type.
- */
- Dwarf_Alloc_Area ah_alloc_area_head;
-
- /* Last Alloc Area that was allocated from. */
- Dwarf_Alloc_Area ah_last_alloc_area;
- };
-
-
- /*
- This struct is used to manage each chunk that is
- malloc'ed for a particular alloc_type. For each
- allocation type, the allocation header points to
- a list of all the chunks malloc'ed for that type.
- */
- struct Dwarf_Alloc_Area_s {
-
- /* Points to the free list of structs in the chunk. */
- Dwarf_Ptr aa_free_list;
-
- /*
- Count of the number of free structs in the chunk.
- This includes both those on the free list, and in
- the blob.
- */
- Dwarf_Sword aa_free_count;
-
- /*
- Points to the first byte of the blob from which
- struct will be allocated. A struct is put on the
- free_list only when it dwrf_deallocated. Initial
- allocations are from the blob.
- */
- Dwarf_Small *aa_blob_start;
-
- /* Points just past the last byte of the blob. */
- Dwarf_Small *aa_blob_end;
-
- /* Points to alloc_hdr this alloc_area is linked to. */
- Dwarf_Alloc_Hdr aa_alloc_hdr;
-
- /*
- Used for chaining Dwarf_Alloc_Area_s atructs.
- Alloc areas are doubly linked to enable deletion
- from the list in constant time.
- */
- Dwarf_Alloc_Area aa_next;
- Dwarf_Alloc_Area aa_prev;
- };
-